<?php
/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 14/12/11
 * Time: 下午4:17
 */

class PubMssql {

    private $conn;

    public function __construct($host, $user, $pwd, $dbName = false){
        $this->conn = mssql_connect($host, $user, $pwd);

        if($dbName) mssql_select_db('URTracker', $this->conn);
    }



    public function getAll($sql){
        $source = mssql_query($sql, $this->conn);

        $result = array();

        if (mssql_num_rows($source)) {
            while ($row = mssql_fetch_array($source, MYSQL_ASSOC)) {

                $tmp[] = array();
                foreach($row as $k=>$v){
                    $tmp[$k] = iconv('GB2312','UTF-8', $v);
                }

                $result[] = $tmp;
            }
        }

        mssql_free_result($source);
        return $result;
    }

} 
